import { Component } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { NzMessageService } from 'ng-zorro-antd/message';
import { _HttpClient } from '@delon/theme';
import { EditComponent } from 'src/app/routes/common/edit/edit.component';
import { SysRoute } from '@api/sys/model/sysRoute.model';
import { SysRouteService } from '@api/sys/service/sysRoute.service';

@Component({
  selector: 'app-sys-route-edit',
  templateUrl: '../../../common/edit/edit.component.html'
})
export class SysRouteEditComponent extends EditComponent<SysRoute, String> {
  constructor(
    public modal: NzModalRef,
    public msgSrv: NzMessageService,
    public http: _HttpClient,
    public sysRouteService: SysRouteService
  ) {
    super(modal, msgSrv, http, sysRouteService);
    this.schema = {
      properties: {
        routeId: { type: 'string', title: '路由ID' },
        routeName: { type: 'string', title: '路由名称' },
        uri: { type: 'string', title: 'uri路径' },
        predicates: { type: 'string', title: '判定器' },
        filters: { type: 'string', title: '过滤器' },
        enabled: {
          type: 'string',
          title: '是否有效',
          enum: [
            { label: '是', value: 1 },
            { label: '否', value: 0 }
          ],
          default: 1
        },
        order: { type: 'integer', title: '排序' },
        description: { type: 'string', title: '描述' }
      },
      required: ['routeId', 'routeName', 'uri']
    };
    this.ui = {
      '*': {
        spanLabelFixed: 100,
        grid: { span: 12 }
      },
      $predicates: {
        widget: 'textarea',
        grid: { span: 24 }
      },
      $filters: {
        widget: 'textarea',
        grid: { span: 24 }
      },
      $description: {
        widget: 'textarea',
        grid: { span: 24 }
      }
    };
  }
}
